<template>
	<view class="YmContent">
		<!-- <uni-steps active-color="#f83d38" :options="[{title: '保费试算'}, {title: '补充资料'}, {title: '身份验证'}, {title: '完成投保'}]" :active="4"></uni-steps> -->
		<view class="main">
			<view class="tip">
				<image src="/static/reg_ok_icon_19.jpg" mode="scaleToFill" border="0" class="icon"></image>
				<text decode="true" class="reg_ok_20">投保成功</text>
				<text decode="true" class="reg_ok_21">在我的订单中可以随时查看购买的产品</text>
			</view>
			
			<uni-row>
				<uni-col :span="12">
					<button type="primary" size="default" @click="fuwht" class="btn-red margin10R">服务合同</button>
				</uni-col>
				<uni-col :span="12">
					<button type="primary" size="default" @click="fuwtk" class="btn-red margin10L">服务条款</button>
				</uni-col>
			</uni-row>
			
			<div class="clear h10"></div>
			<div class="clear h10"></div>
			<div class="clear h10"></div>
			
			<button v-on:click="returnHomePge()" class="btn-red">完成</button>
		</view>

		<view class="ymBbottom"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {

			}
		},
		
		onLoad() {
			uni.setStorageSync("hasReadFuwht", false)
		},
		
		methods: {
			fuwht() {
				uni.request({
					url: getApp().globalData.serviceUrl + "/order/kuybOrder/queryKuybOrderPolicyByMainId",
					data: {
						id: uni.getStorageSync("selectedOrder").id
					},
					method: 'GET',
					header: {
						"X-Access-Token": uni.getStorageSync("token")
					},
					success: (resp) => {
						if (resp.data.success) {
							if(!resp.data.result[0] || !resp.data.result[0].dianzbdxzdz) {
								uni.showToast({
									title: "服务合同还未生成，稍后再试。",
									icon: 'none'
								})
								return
							}
							
							uni.setStorageSync("dianzbdxzdz", resp.data.result[0].dianzbdxzdz)
							uni.navigateTo({
								url:"../../pages2/pdfViewer/pdfViewer"
							})
						}
					}
				});
			},
			
			fuwtk() {
				uni.request({
					url: getApp().globalData.serviceUrl + "/chanp/kuybChanp/queryById",
					data: {
						id: uni.getStorageSync("product").chanpid
					},
					method: 'GET',
					success: (resp) => {
						if (resp.data.success) {
							uni.setStorageSync("fuwtkDetail", resp.data.result)
							uni.navigateTo({
								url:"../../pages2/fuwtkDetail/fuwtkDetail"
							})
						}
					}
				});
			},
			
			returnHomePge() {
				// 人工审核的时候不会立刻生成保单
				// if(!uni.getStorageSync("hasReadFuwht")) {
				// 	uni.showToast({
				// 		title: "请先阅读服务合同和条款后再继续",
				// 		icon: 'none',
				// 		duration: 3000
				// 	});
				// 	return
				// }
				
				uni.switchTab({
					url: '/pages/home/home'
				});
			}
		}
	}
</script>

<style>
	html,
	body,
	#app {
		height: 100%;
		width: 100%;
	}

	.YmContent {
		height: 100%;
		width: 100%;
	}

	uni-page-body,
	#app {
		height: 100%;
	}

	button::after {
		border: none;
		width: auto;
	}

	input {
		outline: none;
		border: none;
		list-style: none;
		width: auto;
	}

	.list_item {
		float: left;
	}

	.ym_hide {
		display: none;
	}

	.ym_show {
		display: block;
	}

	.slide-image {
		width: 100%;
		height: 100%;
	}

	.list_horizontal {
		width: auto;
		display: inline-block;
	}

	.main {
		white-space: normal;
		width: 749upx;
		height: 100%;
		padding: 0upx;
		clear: both;
		float: left;
		background-color: #f5f6fa;
		border-radius: 0upx;
		font-size: 8upx;
	}

	.main .tip {
		white-space: normal;
		width: 749upx;
		height: 384upx;
		padding: 0upx;
		clear: both;
		margin-top: 0upx;
		margin-left: 0upx;
		float: left;
		background-color: #ffffff;
		border-radius: 0upx;
		font-size: 1upx;
		line-height: 1upx;
	}

	.main .tip .icon {
		white-space: normal;
		width: 129upx;
		height: 128upx;
		padding: 0upx;
		clear: both;
		margin-top: 77upx;
		margin-left: 310upx;
		float: left;
		border-radius: 0upx;
		font-size: 8upx;
		line-height: 128upx;
	}

	.main .tip .reg_ok_20 {
		white-space: normal;
		width: 150upx;
		height: 38upx;
		padding: 0upx;
		clear: both;
		margin-top: 25upx;
		margin-left: 299upx;
		float: left;
		text-align: center;
		justify-content: center;
		border-radius: 0upx;
		color: #646464;
		font-size: 32upx;
		line-height: 38upx;
	}

	.main .tip .reg_ok_21 {
		white-space: normal;
		width: 570upx;
		height: 77upx;
		padding: 0upx;
		clear: both;
		margin-top: 20upx;
		margin-left: 90upx;
		float: left;
		text-align: center;
		justify-content: center;
		border-radius: 0upx;
		color: #c8c8c8;
		font-size: 29upx;
		line-height: 35upx;
	}

	.main .btOk {
		white-space: normal;
		width: 703upx;
		height: 93upx;
		padding: 0upx;
		clear: both;
		margin-top: 63upx;
		margin-left: 24upx;
		float: left;
		background-color: #4286f5;
		text-align: center;
		justify-content: center;
		border-radius: 10upx;
		color: #ffffff;
		font-size: 33upx;
		line-height: 93upx;
	}
</style>
